package com.x86.util;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author 风亦未止
 * @date 2022/3/24 19:23
 */
@Data
@ApiModel(value = "响应实体")
public class ResponseResult<T> {
    @ApiModelProperty(value = "响应码")
    private int code;
    @ApiModelProperty(value = "返回信息")
    private String msg;
    @ApiModelProperty(value = "返回数据")
    private T data;

    public ResponseResult(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T>ResponseResult<T> failure(String msg){
        return new ResponseResult<T>(500,msg,null);
    }

    public static <T>ResponseResult<T> success(String msg){
        return new ResponseResult<T>(200,msg,null);
    }

    public static <T>ResponseResult<T> success(String msg,T data){
        return new ResponseResult<T>(200,msg,data);
    }
}
